import config from '@/pages.json'

const defaultName = config.globalStyle.navigationBarTitleText
const pageMap: { [route: string]: string | undefined } = {}

for (const page of config.pages) {
  pageMap[page.path] = page.style.navigationBarTitleText
}

const getTitle = () => {
  const route = getCurrentPages().pop()?.route || ''

  return pageMap[route] || defaultName
}

export { getTitle }
